<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card class="box-card">
      <el-form :model="searchForm" class="demo-form-inline" >
        <el-form-item>
          <el-input style="width:150px;height:30px;"  placeholder="课程名称" v-model="searchForm.cName"></el-input>
          <el-button @click="searchList" style="margin-left: 10px" plain type="info">搜索</el-button>
          <el-button @click="searchEmpty" plain type="info">清空</el-button>
        </el-form-item>
      </el-form>

      <el-table
        :data="orderList"
        stripe
        style="width: 100%">
        <el-table-column
          type="index"
          width="50">
        </el-table-column>
        <el-table-column
          label="订单编号"
          prop="code"
          width="200">
        </el-table-column>
        <el-table-column
          label="学员姓名"
          prop="showName"
          width="120">
        </el-table-column>
        <el-table-column
          label="课程名称"
          prop="courseName"
          width="120">
        </el-table-column>
        <el-table-column
          label="课程价格"
          width="120">
          <template slot-scope="scope">
            ${{scope.row.price}}
          </template>
        </el-table-column>
        <el-table-column
          label="支付时间"
          prop="createTime"
          width="120">
          <template slot-scope="scope">
            {{scope.row.createTime | dateFit('YYYY/MM/DD')}}
          </template>
        </el-table-column>
        <el-table-column
          label="创建日期"
          width="120">
          <template slot-scope="scope">
            {{scope.row.pubTime | dateFit('YYYY/MM/DD')}}
          </template>
        </el-table-column>
        <el-table-column
          label="状态"
          width="120">
          <template slot-scope="scope">
            {{scope.row.status | statusFit}}
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        :current-page="page.currentPage"
        :page-size="page.pageSize"
        :page-sizes="[5, 10, 20, 40]"
        :total="total"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>

    </el-card>
  </div>
</template>

<script>
    export default {
      name: "OrderList",
      data() {
        return {
          searchForm: {cName:null},
          page: {
            currentPage: 0,
            pageSize: 5
          },
          total: 0,
          orderList: [{cid:null}],
          auth: {token: null},
          courseList1:[{id:null}],
          courseList2:[]
        }
      },
      methods: {
        searchEmpty: function () {//清空
          this.searchForm = {}
        },
        handleSizeChange: function (val) {
          this.page.pageSize = val
          this.searchList()
        },
        handleCurrentChange: function (val) {
          this.page.currentPage = val
          this.searchList()
        },
        searchList: function () {//订单列表
          this.$http.post("education-order/eduOrder/list/" + this.page.currentPage + "/" + this.page.pageSize, this.searchForm).then((res) => {
            debugger
            this.orderList = res.data.result.list
            this.total = res.data.result.total
          })
        }
      },
      filters: {
        statusFit: function (val) {
          if (val == 1) return "已支付"
          if (val == 0) return "未支付"
        }
      },
      mounted() {
        this.searchList()//列表展示
      }

    }
</script>

<style scoped>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
